package com.yj.web.WeChat.handler;

import com.yj.web.WeChat.Message.WxXmlMessage;
import com.yj.web.WeChat.Message.WxXmlOutMessage;
import com.yj.web.WeChat.Message.WxXmlOutTextMessage;
import com.yj.web.WeChat.api.WxService;
import com.yj.web.WeChat.service.WxCoreService;
import com.yj.web.util.Session.WxSessionManager;
import com.yj.web.util.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * Created by yanlinyang on 2017/9/20.
 */
@Component
public class ViewHandler extends AbstractHandler {

    @Autowired
    protected WxCoreService coreService;

    @Override
    public WxXmlOutMessage handle(WxXmlMessage wxMessage, Map<String, Object> context, WxService wxService, WxSessionManager sessionManager) throws WxErrorException {
//        WxUser wxUser = coreService.getUserInfo(wxMessage.getFromUser(), "zh_CN");
        WxXmlOutTextMessage m
                = WxXmlOutMessage.TEXT()
                .content("请您在公众号中发送您的问题，我们将及时回复您。")
                .fromUser(wxMessage.getToUser())
                .toUser(wxMessage.getFromUser())
                .build();
        logger.info("subscribeMessageHandler" + m.getContent());
        return m;
    }
}
